﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;
using System.Web.Security;

namespace NCP.Recruiting.WebApp.Models {
    [Serializable]
    public class RecruitingIdentity : IIdentity {
        public RecruitingIdentity(string name, string fullname, string displayName, Guid userId) {
            this.Name = name;
            this.FullName=fullname;
            this.DisplayName = displayName;
            this.UserId = userId;
        }

        public RecruitingIdentity(string name, UserInfo userInfo)
            : this(name, userInfo.FullName,userInfo.DisplayName, userInfo.UserId) {
            if (userInfo == null)
                throw new ArgumentNullException("userInfo");
            this.UserId = userInfo.UserId;
        }

        public RecruitingIdentity(FormsAuthenticationTicket ticket)
            : this(ticket.Name, UserInfo.FromString(ticket.UserData)) {
            if (ticket == null)
                throw new ArgumentNullException("ticket");
        }

        public string Name { get; private set; }

        public string FullName { get; set; }

        public string AuthenticationType {
            get { return "Recruiting"; }
        }

        public bool IsAuthenticated {
            get { return true; }
        }

        public string DisplayName { get; private set; }

        public Guid UserId { get; private set; }
    }
}